package study.java.jdk.jdk8._1_stream.intermediate;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * （1）对于Stream中包含的元素进行去重操作，新生成的Stream中没有重复的元素
 * （2）去重逻辑依赖元素的 equals 方法
 */
@Slf4j
public class distinct_Test {

    @Test
    public void test1() {
        List<String> src = Arrays.asList("s2_switch", "efg", "123", "s2_switch");
        List<String> dest = src.stream()
                .distinct()
                .collect(Collectors.toList());
        log.info("{}", dest);
    }

    @Test
    public void test2() {
        List<String> src = Arrays.asList("s2_switch", "efg", "123", "s2_switch");
        List<String> dest = src.stream()
                .distinct()
                .collect(Collectors.toList());
        log.info("{}", dest);
    }
}
